/*
 * @Author: Jackie
 * @Date: 2020-12-07 15:12:11
 * @FilePath: \vue_demo\vue_mina\src\components\event-utils.js
 * @Copyright (C) 2020 Jackie. All rights reserved.
 * @Description: 日历组件-新增事件的对象
 */
let eventGuid = 0
let todayStr = new Date().toISOString().replace(/T.*$/, '') // 2020/12/07

//事件对象
export const INITIAL_EVENTS = [
  {id: createEventId(),title: '全天-日程',start:"2020-12-06",end:"2020-12-09",color:"#00cedf", textColor: '#fff' },
  {id: createEventId(),title: '时间点-日程',start:"2020-12-10T10:30:00",end:"2020-12-10T11:00:00",color:"#71b8ff",textColor: '#fff' },
  {id: createEventId(),title: '时间点-日程',start:"2020-12-10T12:00:00",end:"2020-12-10T13:45:00",color:"#71b8ff",textColor: '#fff' },
  {id: createEventId(),title: '时间点-日程',start:"2020-12-10T15:45:00",end:"2020-12-10T18:30:00",color:"#71b8ff",textColor: '#fff' },
  {id: createEventId(),title: '时间点-日程',start:"2020-12-10T08:00:00",end:"2020-12-10T09:00:00",color:"#71b8ff",textColor: '#fff' },

  {id: createEventId(),title: '时间点-长日程',start:"2020-12-03",end:"2020-12-05",color:"#6a8d9f",textColor: '#fff' },
  {id: createEventId(),title: '全天-日程',start:"2020-11-30",end:"2020-12-01",color:"#8d5481",textColor: '#fff' },
  {id: createEventId(),title: '测试测试',start:"2020-12-22",end:"2020-12-23",color:"#e87777",textColor: '#fff' },
  {id: createEventId(),title: 'Today-Test',start:todayStr,end:todayStr,color:"#22ccb5",textColor: '#fff'} ,
]
//自增eventGuid
export function createEventId() {
  return String(eventGuid++)
}



export function formatDate(date) {
    let year = date.getFullYear(); // 年
    let month = date.getMonth() + 1; // 月
    let day = date.getDate(); // 日
    let week = date.getDay(); // 星期
    let weekArr = [ "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" ];
    let hour = date.getHours(); // 时
    hour = hour < 10 ? "0" + hour : hour; // 如果只有一位，则前面补零
    let minute = date.getMinutes(); // 分
    minute = minute < 10 ? "0" + minute : minute; // 如果只有一位，则前面补零
    let second = date.getSeconds(); // 秒
    second = second < 10 ? "0" + second : second; // 如果只有一位，则前面补零
    return  `${year}/${month}/${day} ${hour}:${minute}:${second}`;
  }



  export function compare(prop) {
    return function (obj1, obj2) {
        var val1 = obj1[prop];
        var val2 = obj2[prop];if (val1 < val2) {
            return -1;
        } else if (val1 > val2) {
            return 1;
        } else {
            return 0;
        }            
         } 
    }